<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>测试</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <link rel="stylesheet" type="text/css" href="../css/simditor.css" />
    <link rel="stylesheet" type="text/css" href="../css/blog.css" />

    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/module.js"></script>
    <script type="text/javascript" src="../js/hotkeys.js"></script>
    <script type="text/javascript" src="../js/uploader.js"></script>
    <script type="text/javascript" src="../js/simditor.js"></script>
</head>
<body>
    <div class="editor-main">
        <div class="article-title">
            <input id="title" type="text" placeholder="请在此处输入标题" >
        </div>
        <div class="article-content">
            <textarea id="editor" placeholder="Balabala" autofocus></textarea>
        </div>
        <div class="art-block">
            <span>文章标签：</span>
        </div>
        <div class="art-block">
            <span>个人分类：</span>
        </div>
        <div class="art-block">
            <span>文章类型：</span>
        </div>
        <div class="btn-group">
            <input type="button" id="btnPublish" class="btn send" value="发表博客"/>
            <a href="./blogManager.php" id="btnback" class="btn back" >返回</a>
        </div>
    </div>


</body>
<script>
   $(function(){
        Simditor.locale = 'zh-CN';//设置中文
        var editor = new Simditor({
            textarea: $('#editor'),  
            placeholder: '这里输入文字...',
            toolbar:  ['title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent', 'alignment'], //工具条都包含哪些内容
            pasteImage: true,//允许粘贴图片
            //defaultImage: '/res/simditor/images/image.png', //编辑器插入的默认图片
            upload : {
                url : 'richtext_img_upload.do', //文件上传的接口地址
                params: null, //键值对,指定文件上传接口的额外参数,上传的时候随文件一起提交
                fileKey: 'upload_file', //服务器端获取文件数据的参数名
                connectionCount: 3,
                leaveConfirm: '正在上传文件'
            }
        });
        $("#btnPublish").click(function(){
            var title = $("#title").val();
            var article = editor.getValue();
            if(title==''){
                alert("请输入文章标题！");
            }else if(article==''){
                alert("正文不能为空！");
            }else{
                //  调用控制层的方法，并将数据传过去
                datainfo={
                    title:title,
                    article:article
                }
                $.ajax({
                    async:true,
                    url:'./showinfo.php',
                    type:'POST',
                    contentType: "application/x-www-form-urlencoded;charset=utf-8",
                    //dataType: "json",
                    data:datainfo,
                    // success:function(result){
                    //     alert("成功");
                    // }
                });
            }
        });
    });
</script>
</html>